package com.icss.ah.orderList.action;

import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.icss.ah.base.action.BaseAction;
import com.icss.ah.base.bean.EasyuiDataGridJson;
import com.icss.ah.base.bean.Json;
import com.icss.ah.base.bean.WxCorpInfoBean;
import com.icss.ah.base.util.DateUtils;
import com.icss.ah.base.util.ExcelUtil;
import com.icss.ah.express.bean.ExpressGoodsBean;
import com.icss.ah.express.bean.ExpressSheetBean;
import com.icss.ah.express.bean.ExpressUserBean;
import com.icss.ah.login.bean.UserInfoBean;
import com.icss.ah.logistic.service.LogisticService;
import com.icss.ah.orderList.bean.OrderBean;
import com.icss.ah.orderList.bean.OrderSheetBean;
import com.icss.ah.orderList.bean.ProductBean;
import com.icss.ah.orderList.service.OrderListService;
import com.icss.ah.util.ExpressBirdUtil;

import jxl.Workbook;
import jxl.format.Colour;
import jxl.format.UnderlineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import net.sf.json.JSONObject;

/**
 * 已卖出的商品
 *
 */
@Controller
@Scope("prototype")
public class OrderListAction extends BaseAction {

	private static final long serialVersionUID = 4354352341L;

	@Autowired
	private OrderListService orderListService;
	@Autowired
	private LogisticService logisticService;

	private static DecimalFormat df = new DecimalFormat("######0.00");

	/** ==================订阅卡================ **/
	/**
	 * 订阅卡管理页面
	 */
	public String toCardListPage() {
		return "toCardListPage";
	}

	/**
	 * 查询订阅卡列表
	 */
	public void queryCardList() {
		request = this.getRequest();
		String result = "";
		try {
			dataGridJson = new EasyuiDataGridJson();
			HashMap map = new HashMap();
			map.put("cardNo", request.getParameter("cardNo"));// 卡号
			map.put("status", request.getParameter("status"));// 卡号
			map.put("startNo", Integer.valueOf(getStartIndexMysql()));
			map.put("pageRows", Integer.valueOf(getEndIndexMysql()));
			List list = orderListService.queryCardList(map);
			long count = orderListService.queryCardCount(map);// 查询总记录数
			dataGridJson.setRows(list);
			dataGridJson.setTotal(count);
			result = JSONObject.fromObject(dataGridJson).toString();
		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("queryCardList|查询订阅卡列表失败：", e);
		} finally {
			str2Resp(result);
		}
	}

	/** ==================订阅卡================ **/

	/**
	 * 获取支付信息
	 */
	public void getPayInfo() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String orderNo = request.getParameter("orderNo");
			HashMap hm = new HashMap();
			hm.put("orderNo", orderNo);
			Map m = orderListService.getPayInfo(hm);

			jsonText.setSuccess(true);
			jsonText.setObj(m);
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	public String toOrderListPage() {
		request = this.getRequest();
		String returnPage = "toOrderListPage";

		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();

		String frmStartTime = request.getParameter("frmStartTime") == null ? ""
				: request.getParameter("frmStartTime").trim();
		String frmEndTime = request.getParameter("frmEndTime") == null ? "" : request.getParameter("frmEndTime").trim();
		if (frmEndTime.equals("")) {
			frmEndTime = DateUtils.getCurrentDate("yyyy-MM-dd");
			frmStartTime = DateUtils.getMonthByNum(frmEndTime, "yyyy-MM-dd", -1);
		}

		// HashMap map = new HashMap();
		// map.put("shopId", shopId);
		// map.put("corpId", corpId);
		// List yjfl =
		// productForSaleService.getProductType1List("ProductForSaleBean.getProductType1List",
		// map);

		request.setAttribute("frmEndTime", frmEndTime);
		request.setAttribute("frmStartTime", frmStartTime);
		return returnPage;
	}

	public void getOrderList() {
		request = this.getRequest();

		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();

		String fanwei = request.getParameter("fanwei") == null ? "" : request.getParameter("fanwei").trim();
		String maijia = request.getParameter("maijia") == null ? "" : request.getParameter("maijia").trim();
		String dingdanhao = request.getParameter("dingdanhao") == null ? "" : request.getParameter("dingdanhao").trim();
		String chanping = request.getParameter("chanping") == null ? "" : request.getParameter("chanping").trim();
		String state = request.getParameter("state") == null ? "" : request.getParameter("state").trim();
		String stime = request.getParameter("stime") == null ? "" : request.getParameter("stime").trim();
		String etime = request.getParameter("etime") == null ? "" : request.getParameter("etime").trim();

		if (!"".equals(stime) && !"".equals(etime)) {
			fanwei = "";
		}

		String result = "";
		try {
			dataGridJson = new EasyuiDataGridJson();
			HashMap map = new HashMap();
			map.put("corpId", corpId); // 公众号id
			map.put("shopId", shopId); // 商铺id

			map.put("fanwei", fanwei);
			map.put("maijia", maijia);
			map.put("dingdanhao", dingdanhao);
			map.put("chanping", chanping);
			map.put("state", state);
			map.put("stime", stime);
			map.put("etime", etime);

			map.put("startNo", Integer.valueOf(getStartIndexMysql()));
			map.put("pageRows", Integer.valueOf(getEndIndexMysql()));

			// List<Map> orderList = new ArrayList();
			// List<Map> productList = new ArrayList();
			List<OrderBean> headList = new ArrayList<OrderBean>();
			headList = orderListService.getOrderDetailList("OrderListBean.getOrderDetailList", map);
			long orderCount = orderListService.getOrderCount("OrderListBean.getOrderCount", map);// 查询总记录数

			dataGridJson.setRows(headList);
			dataGridJson.setTotal(orderCount);
			result = JSONObject.fromObject(dataGridJson).toString();
			// System.out.println(">>>>>>>>>>result->"+result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			str2Resp(result);
		}
	}

	/**
	 * 订单处理
	 */
	public void agreeOrder() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("ORDER_STATUS", "3");
			hm.put("OPE_DESC", "店家订单处理中");
			boolean result = orderListService.agreeOrder(hm);
			// 写入物流信息 订单已发货
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("UUID", UUID.randomUUID().toString());
			map.put("SHOP_ID", shopId);
			map.put("CORP_ID", corpId);
			map.put("ORDER_NO", orderNo);
			map.put("LOGISTICS_INTO", "订单已处理");
			map.put("LOGISTICS_STATUS", "010002001");
			logisticService.addLogisticInfo("LogisticBean.addLogisticInfo", map);

			jsonText.setSuccess(result);
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 拒单
	 */
	public void RefusedOrder() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("ORDER_STATUS", "3");
			hm.put("OPE_DESC", "店家拒单");
			boolean result = orderListService.RefusedOrder(hm);
			jsonText.setSuccess(result);
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 进入订单发货界面
	 * 
	 * @return
	 */
	public String toShipOrderPage() {
		request = this.getRequest();
		String flag = request.getParameter("flag");
		flag = flag == null ? "" : flag;
		String orderUuid = request.getParameter("orderUuid");
		orderUuid = orderUuid == null ? "" : orderUuid;
		String orderNo = request.getParameter("orderNo");
		orderNo = orderNo == null ? "" : orderNo;
		String orderStatus = request.getParameter("orderStatus");
		orderStatus = orderStatus == null ? "" : orderStatus;
		String orderUuids = request.getParameter("orderUuids");
		orderUuids = orderUuids == null ? "" : orderUuids;
		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String corpId = userInfo.getCorpId();
		String shopId = userInfo.getShopId();
		HashMap map = new HashMap();
		map.put("corpId", corpId); // 公众号id
		map.put("shopId", shopId); // 商铺id
		// 平台物流车辆
		List carList = new ArrayList();
		// 平台物流人员
		List userList = new ArrayList();
		// 自主物流车辆
		List ownerCarList = new ArrayList();
		// 自主物流人员
		List ownerUserList = new ArrayList();
		// carList = orderListService.getWlCarList(map);
		// userList = orderListService.getWlUserList(map);
		// ownerCarList = orderListService.getWlCarList(map);
		// ownerUserList = orderListService.getWlUserList(map);

		map.put("dingdanhao", orderNo);
		OrderBean orderInfo = orderListService.getOrderByOrderNo(map);
		request.setAttribute("orderInfo", orderInfo);

		request.setAttribute("flag", flag);
		request.setAttribute("orderStatus", orderStatus);
		request.setAttribute("orderUuids", orderUuids);
		request.setAttribute("orderUuid", orderUuid);
		request.setAttribute("carList", carList);
		request.setAttribute("userList", userList);
		request.setAttribute("ownerCarList", ownerCarList);
		request.setAttribute("ownerUserList", ownerUserList);
		request.setAttribute("orderNo", orderNo);
		return "toShipOrderPage";
	}

	/**
	 * 发货
	 */
	public void shipOrder() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			String deliverType = request.getParameter("deliverType");
			deliverType = deliverType == null ? "" : deliverType;
			// 发货--添加订单配送信息
			String carOrDeliverUuid = request.getParameter("carOrDeliverUuid");
			carOrDeliverUuid = carOrDeliverUuid == null ? "" : carOrDeliverUuid;
			String orderUuid = request.getParameter("orderUuid");
			orderUuid = orderUuid == null ? "" : orderUuid;

			// String sheet = "订阅成功";
			// if(shipperCode!=null&&!"".equals(shipperCode)) sheet =
			// express(shipperCode,orderNo,carOrDeliverUuid,ifRes,payType);
			// if(sheet.equals(".print_paper {")||sheet.equals("订阅成功")){

			String templateIdD = getTemlateIdByCorp(corpId, "DISPATCHER_MSG"); // 获取templateId
			String templateId = getTemlateIdByCorp(corpId, "WL_INFO"); // 获取templateId
			WxCorpInfoBean corpInfo = getWxCorpInfoBeanByCorpId(corpId);
			String corpSecret = corpInfo.getCorpSecret(); // 获取cropSecret(开发者凭据)
			String corpKey = corpInfo.getCorpKey(); // 获取cropSecret(开发者凭据)

			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("ORDER_STATUS", "4");
			hm.put("MAIL_TYPE", deliverType);
			hm.put("MAIL_ORDER_NO", request.getParameter("orderCode"));
			hm.put("OPE_DESC", "店家已发货");
			// hm.put("deliverType", deliverType);
			hm.put("carOrDeliverUuid", carOrDeliverUuid);
			hm.put("orderUuid", orderUuid);

			// 写入物流信息 订单已发货
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("UUID", UUID.randomUUID().toString());
			map.put("orderUuid", orderUuid);
			map.put("SHOP_ID", shopId);
			map.put("CORP_ID", corpId);
			map.put("ORDER_NO", orderNo);
			map.put("LOGISTICS_INTO", "订单已发货");
			map.put("LOGISTICS_STATUS", "010002002");
			map.put("templateId", templateId);
			map.put("templateIdD", templateIdD);
			map.put("corpSecret", corpSecret);
			map.put("corpKey", corpKey);
			map.put("TMP_ORDER_URL", TMP_ORDER_URL);
			map.put("TMP_DISPATCHER_URL", TMP_DISPATCHER_URL);
			boolean result = orderListService.shipOrder(hm, map);
			if (result == true) {
				// jsonText.setMsg(sheet);
				jsonText.setSuccess(true);
			} else {
				jsonText.setSuccess(false);
			}
			// }else{
			// jsonText.setMsg(sheet);
			// jsonText.setSuccess(true);
			// }
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 批量处理订单
	 */
	public void operateBatch() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderStatus = request.getParameter("orderStatus");
			orderStatus = orderStatus == null ? "" : orderStatus;
			String orderUuids = request.getParameter("orderUuids");
			orderUuids = orderUuids == null ? "" : orderUuids;
			System.out.println("orderUuids:" + orderUuids);

			if (!orderUuids.equals("")) {
				orderUuids = orderUuids.replace(",", "','");

				HashMap hm = new HashMap();
				hm.put("corpId", corpId);
				hm.put("CORP_ID", corpId);
				hm.put("shopId", shopId);
				hm.put("userCode", userCode);
				hm.put("orderStatus", orderStatus);
				hm.put("orderUuids", orderUuids);

				String templateIdD = getTemlateIdByCorp(corpId, "DISPATCHER_MSG"); // 获取templateId
				String templateId = getTemlateIdByCorp(corpId, "WL_INFO"); // 获取templateId
				WxCorpInfoBean corpInfo = getWxCorpInfoBeanByCorpId(corpId);
				String corpSecret = corpInfo.getCorpSecret(); // 获取cropSecret(开发者凭据)
				String corpKey = corpInfo.getCorpKey(); // 获取cropSecret(开发者凭据)
				hm.put("templateId", templateId);
				hm.put("templateIdD", templateIdD);
				hm.put("corpSecret", corpSecret);
				hm.put("corpKey", corpKey);
				hm.put("TMP_ORDER_URL", TMP_ORDER_URL);
				hm.put("TMP_DISPATCHER_URL", TMP_DISPATCHER_URL);

				if (!"".equals(orderStatus)) {
					// 发货--添加订单配送信息
					String carOrDeliverUuid = request.getParameter("carOrDeliverUuid");
					carOrDeliverUuid = carOrDeliverUuid == null ? "" : carOrDeliverUuid;
					String orderUuid = request.getParameter("orderUuid");
					orderUuid = orderUuid == null ? "" : orderUuid;
					String deliverType = request.getParameter("deliverType");
					deliverType = deliverType == null ? "" : deliverType;

					hm.put("deliverType", deliverType);
					hm.put("carOrDeliverUuid", carOrDeliverUuid);
				}
				boolean result = orderListService.operateBatch(hm);
				if (result == true) {
					jsonText.setSuccess(true);
				} else {
					jsonText.setSuccess(false);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 导出订单
	 */
	public void exportOrder() {
		request = this.getRequest();
		response = this.getResponse();
		jsonText = new Json();
		OutputStream os = null;
		try {
			os = response.getOutputStream();// 取得输出流
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderStatus = request.getParameter("orderStatus");
			orderStatus = orderStatus == null ? "" : orderStatus;
			String stime = request.getParameter("stime") == null ? "" : request.getParameter("stime").trim();
			String etime = request.getParameter("etime") == null ? "" : request.getParameter("etime").trim();

			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderStatus", orderStatus);
			hm.put("stime", stime);
			hm.put("etime", etime);

			List<OrderBean> list = orderListService.queryOrderExportList(hm);
			System.out.println("====list:" + list.size());
			if (list != null && !list.isEmpty()) {

				// 生成下载文件
				String fname = getStatusName(orderStatus) + "订单信息";
				response.reset();// 清空输出流

				// 下面是对中文文件名的处理
				// response.setCharacterEncoding("UTF-8");//设置相应内容的编码格式
				response.setContentType("text/html;charset=utf-8");
				// 请求来源浏览器的信息
				String agent = ServletActionContext.getRequest().getHeader("USER-AGENT");
				if (null != agent && -1 != agent.indexOf("Mozilla")) {// 火狐
					response.setHeader("Content-Disposition",
							"attachment;filename=" + new String(fname.getBytes("GB2312"), "ISO-8859-1") + ".xls");
				} else {
					fname = java.net.URLEncoder.encode(fname, "UTF-8");
					response.setHeader("Content-Disposition",
							"attachment;filename=" + new String(fname.getBytes("UTF-8"), "GBK") + ".xls");
				}
				response.setContentType("application/msexcel");// 定义输出类型
				ExcelUtil.createStockExcel(os, list, fname);
			}
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
	}

	private String orderStatus;
	private String stime;
	private String etime;

	/**
	 * 页面打印页
	 * 
	 * @return
	 */
	public String toOrderPrintListPage() {
		String dateStr = DateUtils.getCurrentDate("yyyy/MM/dd HH:mm:ss");
		request = getRequest();
		request.setAttribute("orderStatus", orderStatus);
		request.setAttribute("stime", stime);
		request.setAttribute("etime", etime);
		request.setAttribute("dateStr", dateStr);
		return "toOrderPrintListPage";
	}

	/**
	 * 页面打印页查询
	 */
	public void queryOrderPrintList() {
		request = this.getRequest();
		String result = "";
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			orderStatus = orderStatus == null ? "" : orderStatus;
			stime = stime == null ? "" : stime.trim();
			etime = etime == null ? "" : etime.trim();

			Map<String, String> map = new HashMap<String, String>();
			map.put("corpId", corpId);
			map.put("shopId", shopId);
			map.put("orderStatus", orderStatus);
			map.put("stime", stime);
			map.put("etime", etime);
			map.put("startIndex", getStartIndexMysql());
			map.put("endIndex", (rows * page) + "");

			dataGridJson = orderListService.queryOrderPrintList(map);
			result = JSONObject.fromObject(dataGridJson).toString();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			str2Resp(result);
		}
	}

	/**
	 * 评价回复
	 */
	public void evalOrder() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("ORDER_STATUS", "7");
			hm.put("OPE_DESC", "店家互评");
			boolean result = orderListService.evalOrder(hm);
			jsonText.setSuccess(result);
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 同意退款
	 */
	public void agreeRefund() {
		request = this.getRequest();
		jsonText = new Json();
		boolean result = false;
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			String orderDetailUuid = request.getParameter("orderDetailUuid");
			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("orderDetailUuid", orderDetailUuid);
			hm.put("ORDER_STATUS", "5");
			hm.put("OPE_DESC", "申请退款");

			// 查询支付方式、订单支付信息、退款信息
			HashMap payMap = orderListService.queryPayMap(hm);
			if (payMap.isEmpty()) {
				throw new Exception("不存在支付成功订单，请联系管理员！");
			}

			payMap.put("userCode", userCode);
			payMap.put("orderNo", orderNo);
			String restr = orderListService.agreeRefund(hm, payMap);
			String[] str = restr.split(",");
			if (str[0].equals("1")) {
				jsonText.setSuccess(true);
			} else {
				jsonText.setSuccess(false);
				jsonText.setMsg(str[1]);
			}
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 拒绝退款
	 */
	public void rejectRefund() {
		request = this.getRequest();
		jsonText = new Json();
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			String orderDetailUuid = request.getParameter("orderDetailUuid");
			String reason = request.getParameter("reason");
			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("orderDetailUuid", orderDetailUuid);
			hm.put("reason", reason);
			hm.put("applyStatus", 2);
			boolean result = orderListService.updateRefundStatus(hm);
			jsonText.setSuccess(result);
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(false);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	/**
	 * 修改价格弹出层页面
	 * 
	 * @return
	 */
	public String editPrice() {
		request = this.getRequest();
		String orderNo = request.getParameter("orderNo");
		request.setAttribute("orderNo", orderNo);
		return "editPrice";
	}

	/**
	 * 获得修改价格弹出层页面数据
	 */
	public void getOrderListByOrderNo() {
		request = this.getRequest();

		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();

		String orderNo = request.getParameter("orderNo") == null ? "" : request.getParameter("orderNo").trim();

		String result = "";
		try {
			dataGridJson = new EasyuiDataGridJson();
			HashMap map = new HashMap();
			map.put("corpId", corpId); // 公众号id
			map.put("shopId", shopId); // 商铺id

			map.put("dingdanhao", orderNo);

			map.put("startNo", Integer.valueOf(getStartIndexMysql()));
			map.put("pageRows", Integer.valueOf(getEndIndexMysql()));
			List<OrderBean> headList = new ArrayList<OrderBean>();
			headList = orderListService.getOrderDetailList("OrderListBean.getOrderDetailList", map);
			long orderCount = orderListService.getOrderCount("OrderListBean.getOrderCount", map);// 查询总记录数
			dataGridJson.setRows(headList);
			dataGridJson.setTotal(new Long(orderCount));
			result = JSONObject.fromObject(dataGridJson).toString();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			str2Resp(result);
		}
	}

	/**
	 * 修改价格
	 */
	public void updatePrice() {
		request = this.getRequest();
		jsonText = new Json();
		boolean result = false;
		try {
			String userCode = getUserCodeFromSession();
			UserInfoBean userInfo = getUserInfo(userCode);
			String shopId = userInfo.getShopId();
			String corpId = userInfo.getCorpId();

			String orderNo = request.getParameter("orderNo");
			String discountMoney = request.getParameter("discountMoney");
			String deliverMoney = request.getParameter("deliverMoney");

			HashMap hm = new HashMap();
			hm.put("corpId", corpId);
			hm.put("shopId", shopId);
			hm.put("orderNo", orderNo);
			hm.put("discountMoney", discountMoney);// 折扣或者调整金额，以优惠形式保存，不含修改运费
			hm.put("sum_real_money", request.getParameter("sum_real_money"));// 价格修改后，实付金额
			hm.put("deliverMoney", deliverMoney);

			String restr = orderListService.updatePrice(hm);
			String[] str = restr.split(",");
			if (str[0].equals("1")) {
				jsonText.setSuccess(true);
			} else {
				jsonText.setMsg(str[1]);
			}
			// jsonText.setSuccess(result);
		} catch (Exception e) {
			e.printStackTrace();
			jsonText.setSuccess(result);
		}
		str2Resp(JSONObject.fromObject(jsonText).toString());
	}

	public String showDetail() {
		request = this.getRequest();
		String orderNo = request.getParameter("orderNo");
		request.setAttribute("orderNo", orderNo);
		return "showDetail";
	}

	/**
	 * 退款操作页面
	 * 
	 * @return
	 */
	public String refundOp() {
		request = this.getRequest();
		String orderNo = request.getParameter("orderNo");
		String orderDetailUuid = request.getParameter("orderDetailUuid");
		request.setAttribute("orderNo", orderNo);
		request.setAttribute("orderDetailUuid", orderDetailUuid);
		return "refundOp";
	}

	/**
	 * 优惠详情页面
	 * 
	 * @return
	 */
	public String toDiscountDetailPage() {
		request = this.getRequest();
		String orderNo = request.getParameter("orderNo");
		String createTime = request.getParameter("createTime");
		request.setAttribute("orderNo", orderNo);
		request.setAttribute("createTime", createTime);
		return "toDiscountDetailPage";
	}

	/**
	 * 获得订单优惠详情列表
	 */
	public void getDiscountList() {
		request = this.getRequest();

		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();

		String orderNo = request.getParameter("orderNo") == null ? "" : request.getParameter("orderNo").trim();

		String result = "";
		try {
			dataGridJson = new EasyuiDataGridJson();
			HashMap map = new HashMap();
			map.put("corpId", corpId); // 公众号id
			map.put("shopId", shopId); // 商铺id

			map.put("orderNo", orderNo);
			map.put("ids", "'" + orderNo + "'");

			map.put("startNo", Integer.valueOf(getStartIndexMysql()));
			map.put("pageRows", Integer.valueOf(getEndIndexMysql()));

			List<Map> orderList = orderListService.getOrderList("OrderListBean.getProductList", map);
			List<Map> discountList = orderListService.getDiscountList(map);

			List resultList = new ArrayList();
			resultList.add(orderList);
			resultList.add(discountList);

			dataGridJson.setRows(resultList);
			result = JSONObject.fromObject(dataGridJson).toString();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			str2Resp(result);
		}
	}

	/**
	 * 获得物流时间列表
	 */
	public void queryDeliverList() {
		request = this.getRequest();

		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();

		String orderNo = request.getParameter("orderNo") == null ? "" : request.getParameter("orderNo").trim();

		String result = "";
		try {
			dataGridJson = new EasyuiDataGridJson();
			HashMap map = new HashMap();
			map.put("corpId", corpId); // 公众号id
			map.put("shopId", shopId); // 商铺id

			map.put("orderNo", orderNo);

			List<Map> list = orderListService.queryDeliverList(map);

			dataGridJson.setRows(list);
			result = JSONObject.fromObject(dataGridJson).toString();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			str2Resp(result);
		}
	}

	private String shipperCode;// 快递公司编码
	private String payType;// 邮费支付方式:1-现付，2-到付，3-月结，4-第三方支付
	private final Logger errlog = Logger.getLogger("E");

	public String express(String shipperCode, String orderNo, String orderCode, String ifRes, String payType) {
		String requestType = ifRes != null && "1".equals(ifRes) ? "1008" : "1007";
		String result = "";
		String userCode = getUserCodeFromSession();
		Map<String, String> map = new HashMap<String, String>();
		map.put("userCode", userCode);
		ExpressUserBean sender = orderListService.querySenderInfo(map);
		map.put("orderNo", orderNo);
		ExpressUserBean receiver = orderListService.queryReceiverInfo(map);
		List<ExpressGoodsBean> goodsList = orderListService.queryGoodsList(map);
		double weight = 0.0;
		for (ExpressGoodsBean goods : goodsList) {
			weight += goods.getGoodsWeight();
		}
		ExpressSheetBean bean = new ExpressSheetBean(shipperCode, orderCode, Integer.valueOf(payType), "1", 0, 0,
				receiver, sender, weight, 0, 0.0, "", goodsList, "1");
		map.put("companyName", shipperCode);
		/* 电子面单参数 */
		// Map<String, Object> para = orderListService.queryExpressPara(map);
		// bean.setThrOrderCode("orderCode");
		// bean.setCustomerName((String)para.get(""));
		// bean.setCustomerPwd("");
		// bean.setLogisticCode("");
		// bean.setMonthCode("");
		// bean.setSendSite("");
		String data = JSONObject.fromObject(bean).toString();
		try {
			result = ExpressBirdUtil.orderOnlineByJson(data, getAppKey(), requestType, "2");
			System.out.println(requestType + "========result+==" + result);
			JSONObject obj = JSONObject.fromObject(result);
			if ("1008".equals(requestType)) {
				String Success = obj.getString("Success");
				if (Success.equals("true"))
					result = "订阅成功";
				else
					result = "物流单号为空";
			} else {
				String ResultCode = obj.optString("ResultCode");
				System.out.println("========ResultCode+==" + ResultCode);
				if (ResultCode != null && ResultCode.equals("100")) {
					UserInfoBean userInfo = getUserInfo(userCode);
					String shopId = userInfo.getShopId();
					String corpId = userInfo.getCorpId();
					Map<String, String> hm = new HashMap<String, String>();
					map.put("uuid", UUID.randomUUID().toString());
					map.put("EBusinessID", obj.getString("EBusinessID"));
					map.put("expressJson", result);
					map.put("orderNo", orderNo);
					map.put("corpId", corpId);
					map.put("shopId", shopId);
					map.put("requestType", requestType);
					map.put("UniquerRequestNumber", "");
					JSONObject order = obj.getJSONObject("Order");
					map.put("OrderCode", order.getString("OrderCode"));
					map.put("ShipperCode", order.getString("ShipperCode"));
					map.put("LogisticCode", order.getString("LogisticCode"));
					result = obj.getString("PrintTemplate");
					result = result.replace(".print_paper {", ".print_paper {margin-left: 70px;");
					orderListService.insertSheetInfo(map);
				} else {
					result = obj.getString("Reason");
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
			errlog.error("OrderListAction|express|异常：", e);
		}
		return result;
	}

	private String expressType;// 快递公司类型
	private String ifRes;// 是否预约取件
	// 快递公司列表

	public void queryExpressList() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("expressType", expressType);
		map.put("ifRes", ifRes);
		List<Map<String, Object>> list = orderListService.queryExpressList(map);
		dataGridJson.setRows(list);
		String result = JSONObject.fromObject(dataGridJson).toString();
		str2Resp(result);
	}

	private String orderNo;// 订单号

	public void getOrderSheet() {
		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();
		Map<String, String> map = new HashMap<String, String>();
		map.put("orderNo", orderNo);
		map.put("shopId", shopId);
		map.put("corpId", corpId);
		OrderSheetBean bean = orderListService.queryOrderSheet(map);
		String result = JSONObject.fromObject(bean.getExpressJson()).toString();
		JSONObject obj = JSONObject.fromObject(result);
		result = obj.getString("PrintTemplate");
		result = result.replace(".print_paper {", ".print_paper {margin-left: 70px;");
		str2Resp(result);
	}

	public String getStatusName(String status) {
		String[] str = { "", "等待买家付款", "买家已付款/已下单", "已处理", "已发货", "完成订单", "已评价" };
		status = status == null ? "" : status;
		return str[Integer.valueOf(status)];
	}

	/**
	 * 发票邮寄页面
	 * 
	 * @return
	 */
	public String toExpressBillPage() {
		request = this.getRequest();
		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();
		String orderNo = request.getParameter("orderNo") == null ? "" : request.getParameter("orderNo");
		HashMap map = new HashMap();
		map.put("corpId", corpId); // 公众号id
		map.put("shopId", shopId); // 商铺id
		map.put("orderNo", orderNo);

		List<Map> data = new ArrayList<Map>();
		data = logisticService.getOrderByOrderNo("LogisticBean.getOrderByOrderNo", map);
		String productName = "";
		for (int i = 0; i < data.size(); i++) {
			if (i == (data.size() - 1)) {
				productName += data.get(i).get("PRODUCT_NAME") + "";
			} else {
				productName += data.get(i).get("PRODUCT_NAME") + ",";
			}
		}

		request.setAttribute("orderNo", orderNo);
		request.setAttribute("productName", productName);
		request.setAttribute("orderHead", data.get(0));
		return "toExpressBillPage";
	}

	/**
	 * @title：发票确认邮寄
	 * @method：addLogisticInfo @return：
	 **/
	public void saveExpressBill() {
		request = this.getRequest();
		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();
		String orderNo = request.getParameter("orderNo") == null ? "" : request.getParameter("orderNo");
		String bill_remark = request.getParameter("bill_remark") == null ? "" : request.getParameter("bill_remark");
		String bill_status = request.getParameter("bill_status");
		String templateId = getTemlateIdByCorp(corpId, "WL_INFO"); // 获取templateId
		WxCorpInfoBean corpInfo = getWxCorpInfoBeanByCorpId(corpId);
		String corpSecret = corpInfo.getCorpSecret(); // 获取cropSecret(开发者凭据)
		String corpKey = corpInfo.getCorpKey(); // 获取cropSecret(开发者凭据)
		String result = "1";
		try {
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("UUID", UUID.randomUUID().toString());
			map.put("SHOP_ID", shopId);
			map.put("CORP_ID", corpId);
			map.put("ORDER_NO", orderNo);
			map.put("BILL_REMARK", bill_remark);
			map.put("BILL_STATUS", bill_status);// 1已邮寄
			map.put("templateId", templateId);
			map.put("corpSecret", corpSecret);
			map.put("corpKey", corpKey);
			map.put("TMP_ORDER_URL", TMP_ORDER_URL);
			// 修改发票邮寄状态
			boolean jg = orderListService.saveExpressBill(map);
		} catch (Exception e) {
			e.printStackTrace();
			errlog.info("LogisticAction|addLogisticInfo", e);
			result = "2";
		} finally {
			str2Resp(result);
		}
	}

	public void exportOrderFinish() {
		request = this.getRequest();
		jsonText = new Json();

		String userCode = getUserCodeFromSession();
		UserInfoBean userInfo = getUserInfo(userCode);
		String shopId = userInfo.getShopId();
		String corpId = userInfo.getCorpId();

		String fanwei = request.getParameter("fanwei") == null ? "" : request.getParameter("fanwei").trim();
		String maijia = request.getParameter("maijia") == null ? "" : request.getParameter("maijia").trim();
		String dingdanhao = request.getParameter("dingdanhao") == null ? "" : request.getParameter("dingdanhao").trim();
		String chanping = request.getParameter("chanping") == null ? "" : request.getParameter("chanping").trim();
		// 完成订单
		String state = "5";
		String stime = request.getParameter("stime") == null ? "" : request.getParameter("stime").trim();
		String etime = request.getParameter("etime") == null ? "" : request.getParameter("etime").trim();

		if (!"".equals(stime) && !"".equals(etime)) {
			fanwei = "";
		}

		String result = "";
		try {
			dataGridJson = new EasyuiDataGridJson();
			HashMap map = new HashMap();
			map.put("corpId", corpId); // 公众号id
			map.put("shopId", shopId); // 商铺id

			map.put("fanwei", fanwei);
			map.put("maijia", maijia);
			map.put("dingdanhao", dingdanhao);
			map.put("chanping", chanping);
			map.put("state", state);
			map.put("stime", stime);
			map.put("etime", etime);

			map.put("startNo", Integer.valueOf(getStartIndexMysql()));
			long orderCount = orderListService.getOrderCount("OrderListBean.getOrderCount", map);// 查询总记录数

			map.put("pageRows", orderCount);

			List<OrderBean> headList = new ArrayList<OrderBean>();
			headList = orderListService.getOrderDetailList("OrderListBean.getOrderDetailList", map);

			dataGridJson.setRows(headList);
			dataGridJson.setTotal(orderCount);
			result = JSONObject.fromObject(dataGridJson).toString();
			if (headList != null && headList.size() > 0) {
				downloadExcle(headList, stime, etime);
			} else {
				jsonText.setSuccess(false);
				jsonText.setMsg("未查询到数据,不能下载");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void downloadExcle(List<OrderBean> headList, String begTime, String endTime) {
		response = this.getResponse();
		try {
			String fileName = "完成订单清单";
			OutputStream os = response.getOutputStream();
			response.reset();
			response.setContentType("text/html;charset=utf-8");
			response.setHeader("Content-Disposition",
					"attachment;filename=" + new String(fileName.getBytes("GB2312"), "ISO-8859-1") + ".xls");
			response.setContentType("application/msexcel");

			createExcel(os, fileName, headList, begTime, endTime);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public static void createExcel(OutputStream os, String fileName, List<OrderBean> orderList, String begTime,
			String endTime) throws WriteException, IOException {

		int sellAmountBookTotal = 0; // 总本数
		double realMoneyTotal = 0.0; // 商品价格
		double deliverMoneyTotal = 0.0; // 运费
		double sumRealMoneyTotal = 0.0; // 订单总额

		WritableWorkbook workbook = null;
		try {

			WritableFont wfTitle = new WritableFont(WritableFont.ARIAL, 16, WritableFont.BOLD, false,
					UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
			WritableCellFormat wcfTitle = new WritableCellFormat(wfTitle);

			WritableCellFormat formateTitle = new WritableCellFormat(wcfTitle);
			formateTitle.setAlignment(jxl.format.Alignment.CENTRE);
			formateTitle.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			formateTitle.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
			formateTitle.setWrap(true);

			WritableFont wfc = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false,
					UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
			WritableCellFormat wcfFC = new WritableCellFormat(wfc);

			WritableCellFormat formateTitle1 = new WritableCellFormat(wfc);
			formateTitle1.setAlignment(jxl.format.Alignment.LEFT);
			formateTitle1.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			formateTitle1.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
			formateTitle1.setWrap(true);

			WritableCellFormat formateTitle2 = new WritableCellFormat(wfc);
			formateTitle2.setAlignment(jxl.format.Alignment.RIGHT);
			formateTitle2.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			formateTitle2.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
			formateTitle2.setWrap(true);

			// 属性
			WritableCellFormat formateHead = new WritableCellFormat(wcfFC);
			formateHead.setAlignment(jxl.format.Alignment.CENTRE);
			formateHead.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			formateHead.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
			formateHead.setBackground(Colour.YELLOW);
			formateHead.setWrap(true);

			WritableCellFormat formateBody = new WritableCellFormat();
			formateBody.setAlignment(jxl.format.Alignment.LEFT);
			formateBody.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
			formateBody.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
			formateBody.setWrap(true);

			// 创建工作薄
			workbook = Workbook.createWorkbook(os);
			// 创建新的一页
			WritableSheet sheet = workbook.createSheet(fileName, 0);

			sheet.setRowView(0, 600);
			sheet.setRowView(1, 400);
			sheet.setRowView(2, 600);

			sheet.addCell(new Label(0, 0, fileName, formateTitle));
			sheet.mergeCells(0, 0, 10, 0);

			String timeStr = "时间段选择：";
			if (StringUtils.isNotEmpty(begTime)) {
				timeStr += DateUtils.formatTime(begTime + " 00:00:00", "yyyy年MM月dd日");
			}
			timeStr += "-";
			if (StringUtils.isNotEmpty(endTime)) {
				timeStr += DateUtils.formatTime(endTime + " 00:00:00", "yyyy年MM月dd日");
			}

			sheet.addCell(new Label(0, 1, timeStr, formateTitle2));
			sheet.mergeCells(0, 1, 10, 1);

			// 合计
			int size = orderList.size() + 3; // 最后一行
			sheet.setRowView(size, 600);
			sheet.addCell(new Label(0, size, "合计", formateTitle));
			sheet.mergeCells(0, size, 6, size);
			int col = 0;
			int row = 2;
			sheet.setColumnView(col, 5);
			sheet.addCell(new Label(col++, row, "序号", formateHead));
			sheet.setColumnView(col, 20);
			sheet.addCell(new Label(col++, row, "订户姓名", formateHead));
			sheet.setColumnView(col, 30);
			sheet.addCell(new Label(col++, row, "支付单号", formateHead));
			sheet.setColumnView(col, 40);
			sheet.addCell(new Label(col++, row, "地址", formateHead));
			sheet.setColumnView(col, 20);
			sheet.addCell(new Label(col++, row, "电话", formateHead));
			sheet.setColumnView(col, 15);
			sheet.addCell(new Label(col++, row, "订购日期", formateHead));
			sheet.setColumnView(col, 15);
			sheet.addCell(new Label(col++, row, "商品名称", formateHead));
			sheet.setColumnView(col, 20);
			sheet.addCell(new Label(col++, row, "销售数量", formateHead));
			sheet.setColumnView(col, 15);
			sheet.addCell(new Label(col++, row, "商品金额（元）", formateHead));
			sheet.setColumnView(col, 15);
			sheet.addCell(new Label(col++, row, "运费（元）", formateHead));
			sheet.setColumnView(col, 15);
			sheet.addCell(new Label(col++, row, "订单总额（元）", formateHead));
			for (int i = 0; i < orderList.size(); i++) {
				OrderBean info = orderList.get(i);
				String conName = info.getUSER_NAME();
				String orderNo = info.getORDER_NO();
				String address = info.getPROVINCE() + info.getCITY() + info.getCOUNTY() + info.getCON_ADDRESS();
				String conTel = info.getCON_TEL();
				List<ProductBean> productBeans = info.getProducts();

				Integer sellAmountBook = 0;
				Double realMoney = 0.00;
				StringBuilder sb = new StringBuilder();
				for (ProductBean productBean : productBeans) {
					sellAmountBook = productBean.getSELL_AMOUNT_BOOK() == null ? 0
							: Integer.parseInt(productBean.getSELL_AMOUNT_BOOK());
					realMoney = productBean.getPRODUCT_PRICE() == null ? 0.00
							: Double.parseDouble(productBean.getPRODUCT_PRICE());
					String prN = productBean.getPRODUCT_NAME();
					if (i < productBeans.size() - 1) {
						sb.append(prN + ",");
					} else {
						sb.append(prN);
					}
				}
				String productName = sb.toString();
				String createTime = info.getCREATE_TIME();
				Double deliverMoney = info.getDELIVER_MONEY() == null ? 0.00
						: Double.parseDouble(info.getDELIVER_MONEY());
				Double sumRealMoney = info.getSUM_REAL_MONEY() == null ? 0.00
						: Double.parseDouble(info.getSUM_REAL_MONEY());
				col = 0;
				row = i + 3;
				sheet.setRowView(row, 400);
				sheet.addCell(new Label(col++, row, (i + 1) + "", formateBody));
				sheet.addCell(new Label(col++, row, conName, formateBody));
				sheet.addCell(new Label(col++, row, orderNo, formateBody));
				sheet.addCell(new Label(col++, row, address, formateBody));
				sheet.addCell(new Label(col++, row, conTel, formateBody));
				sheet.addCell(new Label(col++, row, createTime, formateBody));
				sheet.addCell(new Label(col++, row, productName, formateBody));
				sheet.addCell(new Label(col++, row, String.valueOf(sellAmountBook), formateBody));
				sheet.addCell(new Label(col++, row, String.valueOf(df.format(realMoney)), formateBody));
				sheet.addCell(new Label(col++, row, String.valueOf(df.format(deliverMoney)), formateBody));
				sheet.addCell(new Label(col++, row, String.valueOf(df.format(sumRealMoney)), formateBody));

				sellAmountBookTotal += sellAmountBook;
				realMoneyTotal += realMoney; // 商品价格
				deliverMoneyTotal += deliverMoney; // 运费
				sumRealMoneyTotal += sumRealMoney; // 订单总额
			}

			sheet.addCell(new Label(7, size, String.valueOf(sellAmountBookTotal), formateBody));
			sheet.addCell(new Label(8, size, String.valueOf(df.format(realMoneyTotal)), formateBody));
			sheet.addCell(new Label(9, size, String.valueOf(df.format(deliverMoneyTotal)), formateBody));
			sheet.addCell(new Label(10, size, String.valueOf(df.format(sumRealMoneyTotal)), formateBody));

			workbook.write();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (workbook != null) {
				workbook.close();
			}
			if (os != null) {
				os.close();
			}
		}
	}

	public String getExpressType() {
		return expressType;
	}

	public void setExpressType(String expressType) {
		this.expressType = expressType;
	}

	public String getIfRes() {
		return ifRes;
	}

	public void setIfRes(String ifRes) {
		this.ifRes = ifRes;
	}

	public String getShipperCode() {
		return shipperCode;
	}

	public void setShipperCode(String shipperCode) {
		this.shipperCode = shipperCode;
	}

	public String getPayType() {
		return payType;
	}

	public void setPayType(String payType) {
		this.payType = payType;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(String orderStatus) {
		this.orderStatus = orderStatus;
	}

	public String getStime() {
		return stime;
	}

	public void setStime(String stime) {
		this.stime = stime;
	}

	public String getEtime() {
		return etime;
	}

	public void setEtime(String etime) {
		this.etime = etime;
	}

}
